package org.pentaho.di.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

@Controller
public class LoginAction {

    @RequestMapping(value="/loginAction")
    public String login(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        if(username.equals("kettle")&&password.equals("kettle")){
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d, yyyy  HH:mm");
            request.setAttribute("loginTime",sdf.format(date));
            request.setAttribute("userName",username);
            return "index.jsp";
        }else{
            return "loginerror.jsp";
        }
    }
}